<script>
  $('gEditor').retrieve('setTabs',function(){
    var gtabs=$ES('#menu-desktop .spage-side-nav li.l-handle');
    new ItemAgg(gtabs,$ES('#gEditor .spage-main-box'),{
      activeName:'cur',
      onActive:function(tab,item){
        var anotherItems=$$($A(this.items).remove(item));
        if(tab.hasClass('all')){
          anotherItems.show();
          }else{
          anotherItems.hide();
        }
      }
    });
  }());
</script>
<{capture name="sidebar"}>
<div class="side-bx spage-side" style="border-top:none">
    <div class="spage-side-nav">
        <ul>
            <{foreach from=$businessOrder item=business name="sec" key=key}>
                <li class="l-handle<{if $env.foreach.sec.iteration eq 1}> all<{/if}>" ><span><{if $env.foreach.sec.iteration eq 1}><{t}>订单总览<{/t}><{else}><{$business.business_basicmsg.russia_all_name}><{/if}></span></li>                
            <{/foreach}>
        </ul>
    </div>
</div>
<{/capture}>
<div id='gEditor'>
<{foreach from=$businessOrder item=business key=key}>
<input type='hidden' name='childOrder_id[]' value="<{$business.childOrder_id}>">
<div id="business_<{$key}>" class='spage-main-box'>
<h3><{t}>供应商：<{$business.business_basicmsg.russia_all_name}><{/t}></h3>
<div class="division">
   <div class="tableform" >
    <table border="0" cellpadding="0" cellspacing="0" class="gridlist">
			<colgroup>
			<col style="width:20%"></col>
			<col style="width:20%"></col>
			<col style="width:10%"></col>
			<col style="width:10%"></col>
			<col style="width:10%"></col>
			<col style="width:10%"></col>
			<col style="width:15%"></col>
			<col style="width:10%"></col>
			</colgroup>
      <thead>
	  <tr>
        <th><{t}>货号<{/t}></th>
        <th><{t}>商品名称<{/t}></th>
        <th><{t}>商品单价<{/t}></th>
		<th><{t}>购买单价<{/t}></th>
        <th><{t}>合计金额<{/t}></th>
        <!--<td><{t}>购买量<{/t}></td>-->
        <th colspan="3"><{t}>库存确认<{/t}></th>
		</tr>
      </thead>
	  <tbody>
		<{foreach from=$business.order_objects item=obj key=dkey}>
			<tr>
			<input type='hidden' name='obj_id[]' value="<{$obj.obj_id}>">
				<td><{$obj.bn}></td>
				<td><{$obj.name}></td>
				<td><{$obj.price}></td>
				<td><{$obj.buy_price}></td>
				<td><{$obj.amount}></td>
				<!--<td><{$obj.quantity}></td>-->
				<td>
				<{if $obj.goods.goods_confirm=='Y'&&$obj.confirm_num!=''}>
				<span><{$obj.confirm_num}></span>|<{$obj.quantity}>
					<{elseif $obj.goods.goods_confirm=='Y'&&$obj.confirm_num==''}>
					<span>
					<input type='text' name='confirm_num[]' style="width:35px;" value="<{$obj.confirm_num}>">
					</span>|<{$obj.quantity}>
					<{else}>
					<span><{$obj.quantity}></span>|<{$obj.quantity}>
					<{/if}>
				</td>
				<td>
				<{if $obj.goods.goods_confirm=='Y'}>
					<!--<{input type="object" object="goods" filter=$goodslink_filter multiple="true" return_url="{$related_return_url}" rowselect="true"  textcol="name" name="linkid" value=$goods.glink.items view="b2c:admin/goods/detail/rel_items.html"}>-->
				<{/if}>
				</td>
				<td>
					<{if $obj.goods.goods_confirm=='Y'}>
					<button type="submit" class="btn order-goods <{if $obj.confirm_num!=''}>hide<{/if}>" ><span><span><{t}>保存<{/t}></span></span></button>
					<button type="submit" class="btn order-goods-change <{if $obj.confirm_num==''}>hide<{/if}>" ><span><span><{t}>修改<{/t}></span></span></button>
					<{/if}>
				</td>
				
			</tr>
		<{/foreach}>
	  </tbody>
	</table>
  </div>
</div>
</div>
<{/foreach}>
<{capture name='footbar'}>
    <div class="table-action">
		<{button type="button" label=$___b2c="提交"|t:'b2c' id="business_order_confirm_submit"}>
		<{assign var=bclose value="关  闭"}>
		<{assign var=bcclose value=$___b2c='确定退出?'|t:'b2c'}>
        <{button label=$___b2c=$bclose|t:'b2c' class="btn-secondary" onclick="if(confirm('{$bcclose}'))window.close()"}>
	</div>
	<{/capture}>
</div>

<script>
	(function(){
	var _form = $('gEditor');
	var btn =$('business_order_confirm_submit');
	btn.addEvent('click',function(){
		_form.fireEvent('submit',{stop:$empty});
		//window.close();
	});

	$$('.order-goods').addEvent('click',function(){
		this.addClass('hide');
		this.getNext('button').removeClass('hide');
		var tr=this.getParent('tr');
			new Request({
				url:'index.php?app=b2c&ctl=admin_order&act=update_confirm',
				method:'post',
				data:tr.toQueryString()+"&response_json=true",
				onSuccess:function(re){
					location.reload();	
				}
			}).send();
		var num=this.getParent('td').getPrevious('td').getElement('input');
		this.getParent('td').getPrevious('td').getElement('span').set('html',num.value);
	});
	$$('.order-goods-change').addEvent('click',function(){
		this.addClass('hide');
		this.getPrevious('button').removeClass('hide');
		var html=this.getParent('td').getPrevious('td').getElement('span').get('html');
		tpl="<input type='text' name='confirm_num[]' style='width:35px;' value="+html+">"
		this.getParent('td').getPrevious('td').getElement('span').set('html',tpl);
	});
})();
</script>

